﻿using GrapeCity.Forguncy.Commands;
using GrapeCity.Forguncy.Plugin;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vant.CellTypes;
using Vant.Properties;
using Vant.WpfControls.EditorSettings;

namespace Vant.Commands
{
    [Icon("pack://application:,,,/ElementUI;component/Resources/Images/Notification.png")]
    [OrderWeight((int)OrderWeight.Notify)]
    public class Notify : VantCommandBase
    {
        [FormulaProperty]
        [SRDisplayName(nameof(Resources.Notify_Message))]
        public object message { get; set; }

        [SRComboProperty(ValueList = "primary|success|danger|warning|custom", DisplayList = nameof(Resources.Notify_Type_DisplayList))]
        [SRDisplayName(nameof(Resources.Notify_Type))]
        public string type { get; set; } = "danger";

        [ColorProperty()]
        [SRDisplayName(nameof(Resources.Notify_Background))]
        public string background { get; set; } = "Accent 1";

        [ColorProperty()]
        [SRDisplayName(nameof(Resources.Notify_Color))]
        public string color { get; set; } = "white";

        [SRDisplayName(nameof(Resources.Notify_Position))]
        [SRComboProperty(ValueList = "top|bottom", DisplayList = nameof(Resources.Notify_Position_DisplayList))]
        public string position { get; set; } = "top";

        [SRDisplayName(nameof(Resources.Notify_Duration))]
        [SRIntProperty(AllowNull =true, Watermark = nameof(Resources.Notify_Duration_Watermark))]
        [SRDescription(nameof(Resources.Notify_Duration_Description))]
        public int? duration { get; set; }

        [FormulaProperty]
        [SRDisplayName(nameof(Resources.Notify_Context))]
        [SRDescription(nameof(Resources.Notify_Context_Description))]
        public object context { get; set; }

        [SRCustomCommandObject(InitParamProperties = "message|context", InitParamValues = nameof(Resources.Notify_Command_InitParamValues))]
        [SRDisplayName(nameof(Resources.Notify_Command))]
        public object Command { get; set; }

        public override string ToString()
        {
            return Resources.Notify_DisplayName;
        }

        public override bool GetDesignerPropertyVisible(string propertyName, CommandScope commandScope)
        {
            if(propertyName == nameof(background))
            {
                return type == "custom";
            }
            return base.GetDesignerPropertyVisible(propertyName, commandScope);
        }
        public override void InitDefaultPropertyValues()
        {
            base.InitDefaultPropertyValues();
            this.message = Resources.Notify_Message_Default_Value;
            this.duration = 2000;
        }
    }
}
